package com.stone.design.patterns.template;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author Stone
 * @version V1.0
 * @description:
 * @date 4/21/18 15:08
 * @email redsstone@163.com
 */
public class CoffeeWithHook extends CaffeineBeverageWithHook{


    @Override
    void brew() {

    }

    @Override
    void addCondiments() {

    }

    @Override
    boolean customerWantsCondiments() {
        String answer = getUsrInput();
        if (answer.toLowerCase().startsWith("y")) {
            return true;
        } else {
            return false;
        }
    }

    private String getUsrInput() {
        String answer = null;
        System.out.println("would you like milk and sugar with your coffee (y/n)?");
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            answer = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }

        if (answer == null) {
            return "no";
        }

        return answer;
    }

}
